.class final Lcom/greystripe/sdk/a;
.super Ljava/lang/Object;


# instance fields
.field private a:Landroid/hardware/SensorManager;

.field private b:Landroid/hardware/Sensor;

.field private c:Lcom/greystripe/sdk/b;

.field private d:Lcom/greystripe/sdk/aa;

.field private e:Z


# direct methods
.method public constructor <init>(Landroid/content/Context;Lcom/greystripe/sdk/aa;)V
    .locals 2

    const/4 v1, 0x0

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    iput-object p2, p0, Lcom/greystripe/sdk/a;->d:Lcom/greystripe/sdk/aa;

    new-instance v0, Lcom/greystripe/sdk/b;

    invoke-direct {v0, p0, v1}, Lcom/greystripe/sdk/b;-><init>(Lcom/greystripe/sdk/a;B)V

    iput-object v0, p0, Lcom/greystripe/sdk/a;->c:Lcom/greystripe/sdk/b;

    iput-boolean v1, p0, Lcom/greystripe/sdk/a;->e:Z

    const-string v0, "sensor"

    invoke-virtual {p1, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/hardware/SensorManager;

    iput-object v0, p0, Lcom/greystripe/sdk/a;->a:Landroid/hardware/SensorManager;

    return-void
.end method

.method static synthetic a(Lcom/greystripe/sdk/a;)Lcom/greystripe/sdk/aa;
    .locals 1

    iget-object v0, p0, Lcom/greystripe/sdk/a;->d:Lcom/greystripe/sdk/aa;

    return-object v0
.end method


# virtual methods
.method public final declared-synchronized start()V
    .locals 4
    .annotation runtime Landroid/webkit/JavascriptInterface;
    .end annotation

    monitor-enter p0

    :try_start_0
    iget-object v0, p0, Lcom/greystripe/sdk/a;->d:Lcom/greystripe/sdk/aa;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-nez v0, :cond_1

    :cond_0
    :goto_0
    monitor-exit p0

    return-void

    :cond_1
    :try_start_1
    iget-boolean v0, p0, Lcom/greystripe/sdk/a;->e:Z

    if-nez v0, :cond_0

    iget-object v0, p0, Lcom/greystripe/sdk/a;->a:Landroid/hardware/SensorManager;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Landroid/hardware/SensorManager;->getDefaultSensor(I)Landroid/hardware/Sensor;

    move-result-object v0

    iput-object v0, p0, Lcom/greystripe/sdk/a;->b:Landroid/hardware/Sensor;

    iget-object v0, p0, Lcom/greystripe/sdk/a;->a:Landroid/hardware/SensorManager;

    iget-object v1, p0, Lcom/greystripe/sdk/a;->c:Lcom/greystripe/sdk/b;

    iget-object v2, p0, Lcom/greystripe/sdk/a;->b:Landroid/hardware/Sensor;

    const/4 v3, 0x1

    invoke-virtual {v0, v1, v2, v3}, Landroid/hardware/SensorManager;->registerListener(Landroid/hardware/SensorEventListener;Landroid/hardware/Sensor;I)Z

    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/greystripe/sdk/a;->e:Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public final stop()V
    .locals 2
    .annotation runtime Landroid/webkit/JavascriptInterface;
    .end annotation

    iget-object v0, p0, Lcom/greystripe/sdk/a;->a:Landroid/hardware/SensorManager;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/greystripe/sdk/a;->a:Landroid/hardware/SensorManager;

    iget-object v1, p0, Lcom/greystripe/sdk/a;->c:Lcom/greystripe/sdk/b;

    invoke-virtual {v0, v1}, Landroid/hardware/SensorManager;->unregisterListener(Landroid/hardware/SensorEventListener;)V

    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/greystripe/sdk/a;->e:Z

    :cond_0
    return-void
.end method
